//查找峰值
public class leetcode852 {
    public int peakIndexInMountainArray(int[] arr) {
        // int max=0;
        // for(int i=0;i<arr.length;i++){
        //     if(arr[i]>arr[max]){
        //         max=i;
        //     }
        // }
        // return max;
        int left=0;
        int right=arr.length-1;
        while(left<right){
            int mid=left+(right-left+1)/2;
            if(arr[mid]>arr[mid-1]){
                left=mid;
            }else{
                right=mid-1;
            }
        }
        return left;
    }
}
